import dayjs from "dayjs";
export const ChartOptions =  (arrData = [])=>{
    return {
    animationDuration: 10000,
    dataset:{
        dimensions: [
            "createdAt",
            "厂内温度",
            "厂内湿度",
            "固化炉测量温度",
            "水分炉测量温度",
            "粗洗喷淋泵压力值",
            "精洗喷淋泵压力值",
            "脱脂pH值",
            "脱脂喷淋泵压力值",
            "陶化pH值",
            "陶化喷淋泵压力值"
        ],
        source:arrData
    },
    tooltip: {
      order: 'valueDesc',
      trigger: 'axis'
    },
    xAxis:{
      type: 'category',
      nameLocation: 'end',
      axisPointer: {
        value: arrData.length?arrData[0]['createdAt']:"",
        snap: true,
        label: {
            show: true,
            formatter: function(params) {
               return dayjs(params.value).format("YYYY-MM-DD HH:mm:ss");
            }
        },
        handle: {
            show: true
        }
        },
        splitLine: {
            show: false
        },
        axisLabel:{
            formatter: (value, index) =>{
                return dayjs(value).format("YYYY-MM-DD HH:mm:ss");
            }
        }
    },
    yAxis: {
      type:'value',
      min:0
    },
    grid: {
      right: 32,
      left:64,
      bottom:120
    },
    series:[
        {type: 'line',name:'厂内温度',tooltip:{valueFormatter:(value)=>{return `${value}℃`}}},
        {type: 'line',name:'厂内湿度',tooltip:{valueFormatter:(value)=>{return `${value}%`}}},
        {type: 'line',name:'固化炉测量温度',tooltip:{valueFormatter:(value)=>{return `${value}℃`}}},
        {type: 'line',name:'水分炉测量温度',tooltip:{valueFormatter:(value)=>{return `${value}℃`}}},
        {type: 'line',name:'粗洗喷淋泵压力值',tooltip:{valueFormatter:(value)=>{return `${value}Mpa`}}},
        {type: 'line',name:'精洗喷淋泵压力值',tooltip:{valueFormatter:(value)=>{return `${value}Mpa`}}},
        {type: 'line',name:'脱脂pH值',tooltip:{valueFormatter:(value)=>{return `${value}PH`}}},
        {type: 'line',name:'脱脂喷淋泵压力值',tooltip:{valueFormatter:(value)=>{return `${value}Mpa`}}},
        {type: 'line',name:'陶化pH值',tooltip:{valueFormatter:(value)=>{return `${value}PH`}}},
        {type: 'line',name:'陶化喷淋泵压力值',tooltip:{valueFormatter:(value)=>{return `${value}Mpa`}}}
    ],
      encode: {
        x: 'createdAt',
        // y: 'Income',
        // label: ['Country', 'Income'],
        itemName: 'createdAt',
        // tooltip: ['Income']
      },
      tooltip:{
        alwaysShowContent:true,
      }
}
};
